<?php
//**---------------------------------------------------------------------+
//** 通用接口控制器文件 -- 通用
//**---------------------------------------------------------------------+
//** 版权所有：江西佰商科技有限公司. 官网：https://www.tigshop.com
//**---------------------------------------------------------------------+
//** 作者：Tigshop团队，yq@tigshop.com
//**---------------------------------------------------------------------+
//** 提示：Tigshop商城系统为非免费商用系统，未经授权，严禁使用、修改、发布
//**---------------------------------------------------------------------+

namespace app\api\controller\common;

use app\api\IndexBaseController;
use app\service\api\admin\decorate\DecorateService;
use app\service\api\admin\image\Image;
use think\App;
use think\Response;
use utils\Config as UtilsConfig;

/**
 * 首页控制器
 */
class Config extends IndexBaseController
{
    /**
     * 构造函数
     *
     * @param App $app
     */
    public function __construct(App $app)
    {
        parent::__construct($app);
    }

    /**
     * 首页
     *
     * @return Response
     */
    public function base(): Response
    {
        $data = [
            'theme_id' => UtilsConfig::get('theme_id', 'theme_style'),
            'theme_style' => UtilsConfig::getConfig('theme_style'),
            'shop_name' => UtilsConfig::get('shop_name'),
            'shop_title' => UtilsConfig::get('shop_title'),
            'shop_title_suffix' => UtilsConfig::get('shop_title_suffix'),
            'shop_logo' => UtilsConfig::get('shop_logo'),
            'shop_keywords' => UtilsConfig::get('shop_keywords'),
            'shop_desc' => UtilsConfig::get('shop_desc'),
            'storage_url' => app(Image::class)->getStorageUrl(),
            'dollar_sign' => UtilsConfig::get('basic_product', 'base_product', '', 'dollar_sign') ?? '¥',
            'dollar_sign_cn' => UtilsConfig::get('basic_product', 'base_product', '', 'dollar_sign_cn') ?? '元',
            'ico_img' => UtilsConfig::get('ico_img') ?? '',
            'auto_redirect' => UtilsConfig::get('auto_redirect') ?? 1,
            'open_wechat_oauth' => UtilsConfig::get('wechat_oauth', 'base_api_wechat'),
            'person_apply_enabled' => UtilsConfig::get('person_apply_enabled', 'merchant') ?? '',
            'h5_domain' => UtilsConfig::get('h5_domain') ?? '',
            'pc_domain' => UtilsConfig::get('pc_domain') ?? '',
            'show_service' => UtilsConfig::get('kefu_setting', 'base_kefu', '', 'kefu_type') > 0 ? 1 : 0,
            'version_type' => env('VERSION_TYPE', config('app.version_type')),
            'shop_icp_no' => UtilsConfig::get('shop_icp_no'),
            'shop_icp_no_url' => UtilsConfig::get('shop_icp_no_url') ?: 'https://beian.miit.gov.cn',
            'shop_110_no' => UtilsConfig::get('shop_110_no'),
            'shop_110_link' => UtilsConfig::get('shop_110_link') ?: 'https://beian.mps.gov.cn/#/query/webSearch',
            'shop_company' => UtilsConfig::get('shop_company', 'licensed_data'),
            'company_address' => UtilsConfig::get('company_address'),
            'kefu_phone' => UtilsConfig::get('kefu_info','base_kefu','','kefu_phone'),
            'kefu_time' => UtilsConfig::get('kefu_info','base_kefu','','kefu_time'),
            'is_enterprise' => UtilsConfig::get('isEnterprise', 'auto_generate_licensed_data', ''),
            'de_copyright' => UtilsConfig::get('deCopyright', 'auto_generate_licensed_data', ''),
            'powered_by_status' => UtilsConfig::get('powered_by_status', 'base_licensed_data'),
            'powered_by' => UtilsConfig::get('powered_by', 'base_licensed_data'),
        ];
        $data['shop_company'] = $data['de_copyright'] ? $data['shop_company'] : config('app.default_company');
        $preview_id = input('preview_id/d', 0);
        $data['decorate_page_config'] = app(DecorateService::class)->getPcIndexDecoratePageConfig($preview_id);
        return $this->success($data);
    }

    /**
     * 售后服务配置
     * @return Response
     */
    public function afterSalesService(): Response
    {
        return $this->success([
            'item' => UtilsConfig::getConfig('after_sales_service'),
        ]);
    }

}
